<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="logic.newLogic2.Facade3"%>
<%@page import="guiDisplay.MovieList"%>

<html>
<head>
<title>secret 4 plus dog</title>
<meta http-equiv="Content-Type"
	content="text/html; charset=windows-1255">
<link href="secret4.css" rel="stylesheet" type="text/css">
</head>
<%
	String[] movies = null;
	int start = 0;
	MovieList moviesData = null;
	if ((String) session.getAttribute("currentUser") == null) {
		response.sendRedirect("login.jsp");
	} else {
		start = Math.max(0, Integer.parseInt(request
				.getParameter("start")));

		if (request.getParameter("type") != null
				&& Integer.parseInt(request.getParameter("type")) == 1) {
			moviesData = Facade3.getInstance().search(
					request.getParameter("str"), start);
		} else {
			moviesData = Facade3.getInstance().getMovies(start);
		}
		start = Math.min(moviesData.getNumMovies() - 10, start);
		if (start < 0)
			start = 0;
		movies = moviesData.getMovies();
	}
%>
<body bgcolor="#FF6600" dir="ltr">
<a href="login.jsp">Logout</a>    <a href="userPanel.jsp">Main panel</a>
<table height="100%" width="100%" border="0" cellspacing="3"
	cellpadding="2">
	<tr>
		<td width="10%">&nbsp;</td>
		<td valign="top">
		<table height="100%" width="100%" border="0" cellspacing="3"
			cellpadding="2">
			<tr height="20%">
				<td>&nbsp;</td>
			</tr>
			<tr height="80%">
				<td>
				<table align="left" width="100%" border="0" cellspacing="3"
					cellpadding="2">
					<tr>
						<td width="65%" align="left" valign="top">
						<table width="100%" border="0" cellspacing="3" cellpadding="2">
							<tr>
								<td class="title">Rate a movie</td>
							</tr>
							<tr>
								<td>
								<form name="recommendationList" method="post"
									action="facade.jsp"><input type="hidden" name="form"
									value="movieListForRating">
								<table width="100%" border="0" cellspacing="3" cellpadding="2">
									<tr>
										<td>&nbsp;</td>
									</tr>
									<tr>
										<td>
										<table class="bolded" width="100%" border="0" cellspacing="3"
											cellpadding="2">

											<%
												if (movies != null) {
													for (int i = 0; i < movies.length; i++) {
														out.println("<tr>");
														out.println("<td width=\"10%\">" + (start + i + 1)
																+ ".</td>");
														out.println("<td><a href=\"addRating.jsp?movie="
																+ movies[i] + "\">" + movies[i] + "</a></td>");
														out
																.println("<td class=\"rated\">"
																		+ (Facade3
																				.getInstance()
																				.seenMovie(
																						movies[i],
																						(String) session
																								.getAttribute("currentUser")) ? "Rated"
																				: "") + "</td>");
														out.println("<td><a href=\"movieDisplay.jsp?movie="
																+ movies[i] + "\">" + "Details" + "</a></td>");
														out.println("</tr>");
													}
												}
											%>
											<tr>
												<td>&nbsp;</td>
											</tr>
										</table>
										</td>
									</tr>
									<tr>
										<td><a
											href="movieListForRating.jsp?start=<%if (movies != null) {
				out.println(Math.max(0, start - 10));
			}%>">
										<!--input type="submit" class="button"
											name="Previous10movies" value="Previous 10 movies"-->
										Previous 10 movies <!--input type="submit"
											class="button" name="Next10movies"
											value="Next 10 movies"--></a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a
											href="movieListForRating.jsp?start=<%if (movies != null) {
											if (start == moviesData.getNumMovies() - 10)
					out.println(start);
				else
					out.println(start + 10);
			}%>">
										Next 10 movies</a></td>
									</tr>
									<tr>
										<td>For a search, enter part of the movie name:</td>
									</tr>
									<tr>
										<td><input type="text" name="search">&nbsp;<input
											type="submit" name="action" value="Search">
										&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <!--input type="submit"
											class="button" name="action" value="Complete List"--></td>
									</tr>
								</table>
								</form>
								</td>
							</tr>
						</table>
						</td>
						<td valign="top"><img src="Secret4PlusDog.jpg" width="220"
							height="407">
						<p>&nbsp;</p>
						</td>
					</tr>
				</table>
				</td>
			</tr>
		</table>
		</td>
		<td width="10%">&nbsp;</td>
	</tr>
</table>

</body>
</html>

